/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package test1;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.math.BigInteger;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Costel
 */
@Entity
@Table(name = "titulari", catalog = "adminlocal", schema = "")
@NamedQueries({@NamedQuery(name = "Titulari.findAll", query = "SELECT t FROM Titulari t"), @NamedQuery(name = "Titulari.findById", query = "SELECT t FROM Titulari t WHERE t.id = :id"), @NamedQuery(name = "Titulari.findByVersion", query = "SELECT t FROM Titulari t WHERE t.version = :version"), @NamedQuery(name = "Titulari.findByPozitie", query = "SELECT t FROM Titulari t WHERE t.pozitie = :pozitie"), @NamedQuery(name = "Titulari.findByRol", query = "SELECT t FROM Titulari t WHERE t.rol = :rol"), @NamedQuery(name = "Titulari.findByStrada", query = "SELECT t FROM Titulari t WHERE t.strada = :strada"), @NamedQuery(name = "Titulari.findByNr", query = "SELECT t FROM Titulari t WHERE t.nr = :nr"), @NamedQuery(name = "Titulari.findByLocalitateId", query = "SELECT t FROM Titulari t WHERE t.localitateId = :localitateId")})
public class Titulari implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Long id;
    @Column(name = "VERSION")
    private BigInteger version;
    @Basic(optional = false)
    @Column(name = "pozitie")
    private int pozitie;
    @Basic(optional = false)
    @Column(name = "rol")
    private int rol;
    @Column(name = "strada")
    private String strada;
    @Column(name = "nr")
    private String nr;
    @Column(name = "LOCALITATE_ID")
    private BigInteger localitateId;
    @JoinColumn(name = "VOLUM_ID", referencedColumnName = "ID")
    @ManyToOne
    private Volume volumId;
    @JoinColumn(name = "ID", referencedColumnName = "ID", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Volume volume;

    public Titulari() {
    }

    public Titulari(Long id) {
        this.id = id;
    }

    public Titulari(Long id, int pozitie, int rol) {
        this.id = id;
        this.pozitie = pozitie;
        this.rol = rol;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        Long oldId = this.id;
        this.id = id;
        changeSupport.firePropertyChange("id", oldId, id);
    }

    public BigInteger getVersion() {
        return version;
    }

    public void setVersion(BigInteger version) {
        BigInteger oldVersion = this.version;
        this.version = version;
        changeSupport.firePropertyChange("version", oldVersion, version);
    }

    public int getPozitie() {
        return pozitie;
    }

    public void setPozitie(int pozitie) {
        int oldPozitie = this.pozitie;
        this.pozitie = pozitie;
        changeSupport.firePropertyChange("pozitie", oldPozitie, pozitie);
    }

    public int getRol() {
        return rol;
    }

    public void setRol(int rol) {
        int oldRol = this.rol;
        this.rol = rol;
        changeSupport.firePropertyChange("rol", oldRol, rol);
    }

    public String getStrada() {
        return strada;
    }

    public void setStrada(String strada) {
        String oldStrada = this.strada;
        this.strada = strada;
        changeSupport.firePropertyChange("strada", oldStrada, strada);
    }

    public String getNr() {
        return nr;
    }

    public void setNr(String nr) {
        String oldNr = this.nr;
        this.nr = nr;
        changeSupport.firePropertyChange("nr", oldNr, nr);
    }

    public BigInteger getLocalitateId() {
        return localitateId;
    }

    public void setLocalitateId(BigInteger localitateId) {
        BigInteger oldLocalitateId = this.localitateId;
        this.localitateId = localitateId;
        changeSupport.firePropertyChange("localitateId", oldLocalitateId, localitateId);
    }

    public Volume getVolumId() {
        return volumId;
    }

    public void setVolumId(Volume volumId) {
        Volume oldVolumId = this.volumId;
        this.volumId = volumId;
        changeSupport.firePropertyChange("volumId", oldVolumId, volumId);
    }

    public Volume getVolume() {
        return volume;
    }

    public void setVolume(Volume volume) {
        this.volume = volume;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Titulari)) {
            return false;
        }
        Titulari other = (Titulari) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "test1.Titulari[id=" + id + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
